package com.lagou;

import com.lagou.controller.ComsumerComponet;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

import java.io.IOException;
import java.util.concurrent.*;

public class ComsumerMain {
    public static void main(String[] args) throws IOException, InterruptedException {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ComsumerConfiguration.class);
        context.start();
        ComsumerComponet component = context.getBean(ComsumerComponet.class);
        //线程池
        ExecutorService fixedThreadPool = Executors.newFixedThreadPool(30);
        for(;;){
            fixedThreadPool.submit(new Runnable() {
                @Override
                public void run() {
                    try {
                        component.methodA();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
            fixedThreadPool.submit(new Runnable() {
                @Override
                public void run() {
                    try {
                        component.methodB();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
            fixedThreadPool.submit(new Runnable() {
                @Override
                public void run() {
                    try {
                        component.methodC();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            });
        }

    }
    @Configuration
    @EnableDubbo
    @PropertySource("classpath:/dubbo-comsumer.properties")
    @ComponentScan("com.lagou.controller")
    static class ComsumerConfiguration{

    }
}
